﻿using GeoJSON.Net.Geometry;
using GeoJSON.Net.Contrib.Wkb;
using Newtonsoft.Json;
using SPW.Infrastructure.Enums;
using SPW.Infrastructure.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GeoJSON.Net.Feature;

namespace SPW.Infrastructure.Models
{
    /// <summary>
    /// 绘制结果
    /// </summary>
    public class DrawResult
    {
        /// <summary>
        /// GeoJSON.Net 要素对象
        /// </summary>
        public IGeometryObject Geometry { get; private set; }
        public Feature Feature { get; private set; }

        /// <summary>
        /// 创建点绘制结果
        /// </summary>
        /// <param name="id">要素id</param>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <param name="altitude"></param>
        public DrawResult(string id, double latitude, double longitude, double? altitude = null)
        {
            Geometry = new Point(new Position(latitude, longitude, altitude));
            Feature = new Feature(Geometry, null, id);
        }

        /// <summary>
        /// 根据wkb值创建绘制结果
        /// </summary>
        /// <param name="id">要素id</param>
        /// <param name="wkb"></param>
        public DrawResult(string id, byte[] wkb)
        {
            Geometry = wkb.ToGeoJSONGeometry();
            Feature = new Feature(Geometry, null, id);
        }
    }
}
